import TJavaLib.TList;
import TJavaLib.TString;
import TJavaLib.TGraphic;
import java.awt.Color;
import java.awt.Font;

public class TSensor extends TNode {
	public static final byte FORWARDER = 0;
	public static final byte DESTINATION = 1;
	public static final byte REPLICATION = 2;
	public static final byte NORMAL = 3;

	private static long autoID = 0;
	public static void resetID() { autoID = 0; }
	
	private long ID;
	private byte type;

	public TSensor() {
		super(TNode.SENSOR);
		
		ID = autoID++;
		deco.shape = TDeco.CIRCLE;
		deco.radius = 10;
		deco.fillColor = Color.gray;
		deco.textColor = TGraphic.getColor("#680000");
		deco.font = new Font("Arial", Font.BOLD, 10);
		type = NORMAL;
		
		radio.setAddr("s"+String.valueOf(ID));
	}
	
	public void setType(byte t) { 
		type = t;
		if (type==TSensor.DESTINATION)
			deco.fillColor = TGraphic.getColor("#7A0101");
		else if (type==TSensor.FORWARDER)
			deco.fillColor = Color.blue;
		else if (type==TSensor.REPLICATION)
			deco.fillColor = Color.red;
		else if (type==TSensor.NORMAL)
			deco.fillColor = Color.gray;
	}
	
	public byte getType() { return type; }
}
